home *** CD-ROM | disk | FTP | other *** search
/ Aminet 21 / Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso / Aminet / comm / www / 1stLinkChecker.lha / 1st_LinkChecker / LinkChecker < prev    next >
Text File  |  1997-08-08  |  4KB  |  176 lines

  1. /* Optimized with RexxOpt 1.7 */
  2.  
  3. NL='0A'X
  4. TempFile="ram:HTMLfound"
  5. say "************************************************"
  6. say "* Local Link Checker V1.3 (08/07/97)           *"
  7. say "* © Heiko Schröder (age@thepentagon.com)       *"
  8. say "************************************************"||NL
  9. if ~show('L',"rexxreqtools.library") then;do
  10. if ~addlib('rexxreqtools.library',0,-30,0) then;do
  11. say "You need LIBS:rexxreqtools.library. Cancel"
  12. Call Fini
  13. END
  14. END
  15. Ext.0=6
  16. Ext.1="HTTP://"
  17. Ext.2="FTP://"
  18. Ext.3="GOPHER://"
  19. Ext.4="MAILTO:"
  20. Ext.5="NEWS:"
  21. Ext.6="ABOUT:"
  22. verz=GetClip("xdir")
  23. dir=rtfilerequest(verz,,"Where can I search? Pick Dir and OK",,"rtfi_flags = freqf_nofiles")
  24. if rtresult=0 then;do
  25. echo "Cancel"
  26. Exit
  27. End
  28. pat="PAT=#?.#?(htm|html)"
  29. say "Checking: "||dir
  30. void=SetClip("xdir",dir)
  31. directory=dir
  32. if dir~="" then dir=d2c(34)||dir||d2c(34)
  33. address command "list >"TempFile dir pat||" quick nohead files all lformat %s%s"
  34. Time('R')
  35. Datei=0;Fehler=0;Links=0
  36. Open("LCR","T:LinkCheckResult","W")
  37. Open("HTML",TempFile,"R")
  38. DO WHILE 1
  39. htmlfile=ReadLn('HTML')
  40. IF EOF('HTML') THEN leave
  41. poss=max(pos(":",htmlfile),lastpos("/",htmlfile))
  42. verz=left(htmlfile,poss)
  43. help=verz
  44. Datei=Datei+1
  45. ende=0
  46. zeile=0
  47. say d2c(11)||copies(" ",70)||d2c(11)
  48. say "Checking: "DelStr(htmlfile,1,length(directory))
  49. say "Files: "||Datei||" - Links: "||links||" - Errors: "||Fehler||""d2c(11)
  50. Open("CHECK",htmlfile,"R")
  51. DO WHILE ende=0
  52. Do WHILE ende=0
  53. line=Readln('CHECK')
  54. IF EOF('CHECK') THEN ende=1
  55. zeile=zeile+1
  56. DO WHILE 1
  57. raus=0;z=1
  58. pos11=pos('SRC=',upper(line));if pos11=0 then pos11=99999
  59. pos12=pos('HREF=',upper(line));if pos12=0 then pos12=99999
  60. pos1=min(pos11,pos12)
  61. IF pos1=99999 then leave
  62. pos13=min(pos('=',line,pos1),pos('="',line,pos1))
  63. Select
  64. When pos13=0 then pos1=pos('=',line,pos1)
  65. When pos13<pos1+7 then pos1=pos13
  66. Otherwise NOP
  67. End
  68. pos21=pos(d2c(34),line,pos1+2);if pos21=0 then pos21=99999
  69. pos22=pos(" ",line,pos1+2);if pos22=0 then pos22=99999
  70. pos23=pos("#",line,pos1+2);if pos23=0 then pos23=99999
  71. pos24=pos(">",line,pos1+2);if pos24=0 then pos24=99999
  72. pos2=min(pos21,pos22,pos23,pos24)
  73. IF pos2=99999 then leave
  74. link=left(line,pos2-1)
  75. Do While (raus=0&z<7)
  76. Call Extern Ext.z
  77. z=z+1
  78. end
  79. line=Delstr(line,1,pos2+1)
  80. if raus=0 then;do
  81. link=DelStr(link,1,pos1)
  82. link=strip(link,B,d2c(34))
  83. link=strip(link,B,"=")
  84. pos3=0
  85. hilfsverz=left(verz,Length(verz)-1)
  86. Do While 1
  87. pos3=pos("../",link)
  88. if pos3 ~=0 then;do
  89. link=DelStr(link,pos3,pos3+2)
  90. posx=pos(":",hilfsverz)
  91. posy=lastpos("/",hilfsverz)
  92. pos4=max(posx,posy)
  93. if pos4~=0 then hilfsverz=Left(hilfsverz,pos4-1)
  94. help=verz
  95. If pos4~=posx then verz=hilfsverz||"/"
  96. else verz=hilfsverz||":"
  97. end
  98. else leave
  99. End
  100. links=links+1
  101. if exists(verz||link)~=1 then;do
  102. Fehler=Fehler+1
  103. writeln("LCR",htmlfile||" -> "||link||" -> line: "||zeile)
  104. end
  105. say "Files: "||Datei||" - Links: "||links||" - Errors: "||Fehler||""d2c(11)
  106. verz=help
  107. END
  108. END
  109. END
  110. END
  111. Close("CHECK")
  112. END
  113. Close("HTML")
  114. Close("LCR")
  115. Zeit=TIME('E')
  116. address command "delete ram:HTMLfound QUIET"
  117. say "Files: "||Datei||" - Links: "||links||" - Errors: "||Fehler||""
  118. If Fehler~=0 then
  119. say "Sorry. There were link errors. They are listed in T:LinkCheckResult."
  120. else
  121. say "Great. No local link errors :-)"
  122. SAY "Elapsed time: "Zeit" sec."
  123. Open("LCR","T:LinkCheckResult","R")
  124. z=0
  125. File.0=Fehler
  126. Link.0=Fehler
  127. Line.0=Fehler
  128. DO WHILE 1
  129. line=ReadLn('LCR')
  130. IF (EOF('LCR')|line='') THEN leave
  131. z=z+1
  132. pos1=pos(" -> ",line)
  133. pos2=pos(" -> ",line,pos1+1)
  134. File.z=Left(line,pos1)
  135. Link.z=Delstr(line,1,pos1+3);Link.z=Left(Link.z,pos2-pos1-4)
  136. Line.z=Delstr(line,1,pos2+9)
  137. End
  138. Close("LCR")
  139. if z=0 then Call Fini
  140. quit=0;del=0;t=1
  141. Do While quit=0
  142. call rtezrequest("Error: "t"/"Fehler||NL||" File: "File.t||NL||" Link: "Link.t||NL||" Line: "Line.t,"Prev|Next|I know|Leave","» Link Errors «",,fonttag "rtez_defaultresponse = 1",result)
  143. if (result=1&t~=1) then t=t-1
  144. if (result=2&t~=z) then t=t+1
  145. if result=3 then del=1
  146. if result=0 then quit=1
  147. if del=1 then;do
  148. if z~=t then;do
  149. do r=t to z-1
  150. e=r+1
  151. File.r=File.e
  152. Link.r=Link.e
  153. Line.r=Line.e
  154. end
  155. end
  156. else;do
  157. r=t-1
  158. t=t-1
  159. end
  160. File.0=r;if r=0 then quit=1
  161. Link.0=r
  162. Line.0=r
  163. z=z-1
  164. Fehler=Fehler-1
  165. del=0
  166. end
  167. End
  168. exit
  169. Extern:
  170. Parse ARG tag
  171. tagpos=pos(tag,upper(link))
  172. if (tagpos<pos1+7&tagpos~=0) then raus=1
  173. RETURN
  174. Fini:
  175. PARSE PULL Keyword
  176. exit